package com.wc.alorithm_luogu.P8825;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/11/10 14:43
 * @description [传智杯 #3 初赛] 运气
 * https://www.luogu.com.cn/problem/P8825
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long k = sc.nextLong();
        long min = 0;
        long max = 0;
        long one = 1;
        long six = 6;
        long mod = 1000000000 + 7;
        long bound = (long) Math.pow(10, n - 1);
        for (int i = 0; i < n; i++) {
            min = min * 10 + one;
            max = max * 10 + six;
        }
        long ans = max / k - (min - 1) / k;
        long leftBound;
        long rightBound;
        for (int j = 0; j < n; j++) {
            for (int i = 1; i < six; i++) {
                rightBound = min - 1 + bound * i;
                leftBound = max + 1 - bound * i;
                ans = ans + (leftBound - 1) / k - rightBound / k;
            }
            bound /= 10;
        }


//        System.out.println(ans);
        System.out.println(ans % mod);
    }
}

